Skip to content

Add deployable Computer MCP example - #28

Open
scuffi wants to merge 1 commit into
mainfrom
workspace-codemode-adapter
Open

Add deployable Computer MCP example#28
scuffi wants to merge 1 commit into
mainfrom
workspace-codemode-adapter

Conversation

@scuffi

@scuffi scuffi commented Jul 31, 2026

Copy link
Copy Markdown

Computer already provides durable filesystem and command tools, but the repository did not show how to expose them through a remote MCP server. This adds examples/mcp, a deployable single-user example built with @cloudflare/codemode.

MCP clients see one public code tool. Code Mode turns the internal Computer tools into codemode.read, codemode.ls, codemode.write, codemode.edit, and codemode.exec functions that the model can combine in one call. The workspace belongs to one durable object, so files persist between MCP requests.

worker-shell is the fast default and has no ambient outbound network access, though its built-in Git command supports HTTPS remotes. A model can select container-shell when it needs Debian, Node.js, npm, native binaries, or package downloads. The container starts on demand, and Computer synchronizes /workspace through its FUSE mount. Code Mode itself runs in an isolated Dynamic Worker without outbound network access.

For example, the model can use the public code tool to run:

async () => {
  await codemode.write({
    path: "/workspace/message.txt",
    content: "hello from Code Mode",
  });

  const file = await codemode.read({ path: "/workspace/message.txt" });
  const shell = await codemode.exec({
    command: "node --version",
    backend: "container-shell",
  });

  return { content: file.content, node: shell.stdout.trim() };
}

The MCP endpoint requires a bearer token and fails closed until MCP_TOKEN is configured. To deploy from a clone and set the secret:

npm install
npm run deploy --workspace @example/computer-mcp
openssl rand -hex 32
npx wrangler secret put MCP_TOKEN --config examples/mcp/wrangler.jsonc

Clients connect to https://<worker>.workers.dev/mcp over Streamable HTTP and send Authorization: Bearer <MCP_TOKEN>. The README also covers the Deploy to Cloudflare button, client configuration, backend selection, local development, debugging, and the single-user security model.

The workerd integration test connects a real MCP client, verifies authentication and the one-tool interface, exercises filesystem and Worker-shell operations, checks persistence, and confirms that Code Mode cannot reach the network directly. Type checking, repository checks, and the Wrangler deployment dry-run also pass.

@pkg-pr-new

pkg-pr-new Bot commented Jul 31, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@cloudflare/computer@28

commit: d2a7d0d

@aron-cf
aron-cf changed the base branch from workspace-runtime-execution to workspace-javascript-backend July 31, 2026 12:11
@scuffi
scuffi force-pushed the workspace-codemode-adapter branch 3 times, most recently from 6b8cd20 to be031a6 Compare July 31, 2026 12:35
Base automatically changed from workspace-javascript-backend to workspace-runtime-execution July 31, 2026 14:14
Base automatically changed from workspace-runtime-execution to main July 31, 2026 14:19
@scuffi
scuffi force-pushed the workspace-codemode-adapter branch from be031a6 to c6048e3 Compare July 31, 2026 14:38
@aron-cf aron-cf closed this Jul 31, 2026
@aron-cf
aron-cf force-pushed the workspace-codemode-adapter branch from c6048e3 to f1cf132 Compare July 31, 2026 14:38
@scuffi scuffi reopened this Jul 31, 2026
@scuffi
scuffi force-pushed the workspace-codemode-adapter branch from c6048e3 to 509bf0d Compare July 31, 2026 15:10
@aron-cf

aron-cf commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

Trying to figure out if we need this on top of the existing backend. I'm not sure what it would be used for. What are your thoughts?

@scuffi
scuffi force-pushed the workspace-codemode-adapter branch from 509bf0d to b2e6e91 Compare August 3, 2026 10:35
@scuffi scuffi changed the title Add external Codemode runtime adapter example Add Computer tools as a Codemode MCP example Aug 3, 2026
@aron-cf aron-cf changed the title Add Computer tools as a Codemode MCP example Add example showing how to setup an MCP server for a workspace Aug 3, 2026
@scuffi
scuffi force-pushed the workspace-codemode-adapter branch 2 times, most recently from 5cb656e to 652d3bd Compare August 3, 2026 15:53
@scuffi
scuffi marked this pull request as ready for review August 3, 2026 16:06

@aron-cf aron-cf left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, left some early comments.

Comment thread examples/codemode/src/codemode.integration.test.ts Outdated
Comment thread examples/codemode/src/computer-mcp.ts Outdated
Comment thread examples/codemode/src/computer-mcp.ts Outdated
Comment thread examples/codemode/src/computer-mcp.ts Outdated
Comment thread examples/codemode/src/index.ts Outdated
@aron-cf

aron-cf commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Hey @agent-think can you deploy a version of this MCP server example, then can you:

(1) do some light smoke testing of file based workflows.
(2) report back with the full interface of the Code Mode server that you were able to discover using the server (without using the source code as a reference)

@scuffi
scuffi force-pushed the workspace-codemode-adapter branch from 652d3bd to d58edb0 Compare August 10, 2026 19:44
@changeset-bot

changeset-bot Bot commented Aug 10, 2026

Copy link
Copy Markdown

鈿狅笍 No Changeset found

Latest commit: d2a7d0d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@scuffi scuffi changed the title Add example showing how to setup an MCP server for a workspace Add deployable Computer MCP example Aug 10, 2026
devin-ai-integration[bot]

This comment was marked as resolved.

@scuffi
scuffi force-pushed the workspace-codemode-adapter branch 2 times, most recently from b6b728d to 53d2750 Compare August 10, 2026 19:50
devin-ai-integration[bot]

This comment was marked as resolved.

@scuffi
scuffi force-pushed the workspace-codemode-adapter branch 3 times, most recently from 3e37b7c to cf739d1 Compare August 11, 2026 10:50
devin-ai-integration[bot]

This comment was marked as resolved.

@scuffi
scuffi force-pushed the workspace-codemode-adapter branch 2 times, most recently from c3a8329 to d97a33e Compare August 11, 2026 13:01
devin-ai-integration[bot]

This comment was marked as resolved.

@scuffi
scuffi force-pushed the workspace-codemode-adapter branch from d97a33e to a6a5621 Compare August 11, 2026 13:43
@scuffi
scuffi force-pushed the workspace-codemode-adapter branch from a6a5621 to d2a7d0d Compare August 11, 2026 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants